package com.yyj.service;

import com.yyj.dao.CalendarDao;
import com.yyj.entity.Calendar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CalendarService {
    @Autowired
    private CalendarDao calendarDao;

    public List<Calendar> getCalendar(Integer userId) {
        List<Calendar> list = calendarDao.getCalendar(userId);
        return list;
    }

    //添加或者修改
    public void saveCalendar(Calendar calendar) {
        //查
        Calendar date = calendarDao.getByDate(calendar);
        if (date == null) {
            //添加
            calendarDao.saveCalendar(calendar);
        } else {
            calendarDao.update(calendar);
        }


    }

    public Calendar getByDate(Calendar calendar) {
        Calendar list = calendarDao.getByDate(calendar);
        return list;
    }
}
